package com.lingyuan.product.controller;

import com.lingyuan.common.core.domain.R;
import com.lingyuan.product.domain.BrandEntity;
import com.lingyuan.product.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName BrandController
 * @Description 描述
 * @Author guoxin
 * @Date 2024/9/19 20:18
 */
@RestController
@RequestMapping("/brand")
public class BrandController {
    @Autowired
    private BrandService brandService;
    /**
     * 品牌列表
     */
    @GetMapping("/brandList")
    public R brandList(){
      List<BrandEntity> list =  brandService.brandList();
      return R.ok(list);
    }
    /**
     * 功能: 添加品牌
     */
    @PostMapping("/addBrand")
    public R addBrand(@RequestBody BrandEntity brandEntity){
        brandService.save(brandEntity);
        return R.ok("添加成功");
    }
    /**
     * 功能:修改品牌
     */
    @PutMapping("/updBrand")
    public R updBrand(@RequestBody BrandEntity brandEntity){
        brandService.updateById(brandEntity);
        return R.ok("修改成功");
    }
    /**
     * 删除品牌
     */
    @DeleteMapping("del/{brandId}")
    public R delBrand(@PathVariable("brandId") Long brandId){
        brandService.removeById(brandId);
        return R.ok("删除成功");
    }
}
